package com.tradeplus.admin.dao;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.tradeplus.admin.model.State;

public class StateDaoImpl implements StateDao {
	
	private HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
        this.hibernateTemplate = hibernateTemplate;
    }

	@Override
	public void saveState(State state) {
		hibernateTemplate.merge(state);
	}

	@Override
	public List<State> loadState() {
		return hibernateTemplate.find("from State");
	}

	@Override
	public void deleteState(Long stateId) {
		hibernateTemplate.delete(hibernateTemplate.get(State.class, stateId));
	}

	@Override
	public State loadStateById(Long stateId) {
		return (State)hibernateTemplate.get(State.class, stateId);
	}

}
